<?php
/*
 * @Author: Mr.Mao
 * @Date: 2021-11-01 11:43:29
 * @Last Modified by: Mr.Mao
 * @LastEditTime: 2021-11-01 14:57:07
 * @Description: 游客等级表
 */
namespace app\member\model;
use app\BaseModel;
use think\facade\Cache;
class UsersLevelModel extends BaseModel
{
	protected $table = 'users_level';
	public  $pk = 'level_id';
	protected static $mkey = 'users_level_list';

	 /*------------------------------------------------------ */
	//-- 清除缓存
	/*------------------------------------------------------ */
	public function cleanMemcache(){
		Cache::rm(self::$mkey);
	}
	/*------------------------------------------------------ */
	//-- 获取列表
	/*------------------------------------------------------ */
	public  function getRows(){
		$data = Cache::get(self::$mkey);
		if (empty($data) == false){
			return $data;
		}
		$rows = $this->order('update_time','asc')->select()->order('update_time','asc')->toArray();
		foreach ($rows as $row){
			// $row['value'] = json_decode($row['value'] , true);
			$data[$row['level_id']] = $row;
		}
		//ksort($data);
		Cache::set(self::$mkey,$data,600);
		return $data;
	}

	public function info($level_id = 0)
	{
		return $this->find($level_id)->toArray();
	}

}
